package com.example.demo.system.controller;

import com.example.demo.system.entity.File;
import com.example.demo.system.service.FileService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.validation.constraints.NotBlank;
import javax.validation.Valid;
/**
* @author 许久龙
* @since 2022-02-19
*/
@RestController
@RequestMapping("api")
public class FileController {

    @Autowired
    private FileService fileService;

    @GetMapping("/file")
    @ApiOperation("File查询单个")
    public ResultVO getFile(@RequestBody File file){
     ResultVO resultVO = fileService.getFile(File file);
     return  resultVO;
   }

    @GetMapping("/file")
    @ApiOperation("File查询全部")
    public ResultVO getAllFile(){
        ResultVO resultVO = fileService.getAllFile();
        return  resultVO;
    }

    @PostMapping("/file")
    @ApiOperation("File新增")
    public ResultVO add(@Valid @RequestBody File file) {
        ResultVO resultVO = fileService.add(File file);
        return  resultVO;
    }

    @PutMapping("/file")
    @ApiOperation("File修改")
    public ResultVO update(@Valid @RequestBody File file) {
        ResultVO resultVO = fileService.update(File file);
        returnresultVO;
    }


    @DeleteMapping(value = "/file/{ids}")
    @ApiOperation("File删除(单个条目)")
    public ResultVO remove(@NotBlank(message = "{required}") @PathVariable String ids) {
        ResultVO resultVO = fileService.remove(String ids);
        return resultVO;
    }
}
